-- CALC_DUNGEON_MONSTER_INIT_ATTACK
-- 计算地牢怪物的初始攻击

-------------------
-- @param attackCoef attack系数
-- @param layer      地牢层数
return function(attackCoef, layer, layer_fix)
    -- b + ax
    local att_b = 0.16 * layer_fix * (attackCoef + 10) / 20;
    local att_a = attackCoef * (60 + layer_fix) / 3500;
    local attack = 0;

    if layer < 30 then
        -- 在比较小层的情况下，精确计算
        local a_fix = math.modf(10 * attackCoef);
        local num = 56 * layer_fix * (a_fix + 100) + 2 * (60 + layer_fix) * a_fix * layer;
        local deno = 70000;

        local ret = math.modf(num / deno);
        if num % deno ~= 0 then
            ret = ret + 1;
        end

        return ret;
    elseif layer < 40 then
        attack = att_b + att_a * layer * layer / 30;
    elseif layer < 60 then
        attack = att_b + att_a * layer * layer / 30 * layer / 40;
    elseif layer < 80 then
        attack = att_b + att_a * layer * layer / 30 * layer / 40 * layer / 60;
    else
        attack = att_b + att_a * layer * layer / 30 * layer / 40 * layer / 60 * layer / 80;
    end

    -- 为保证服务器客户端计算一致，先做如此处理
    attack = tonumber(string.format("%.2f", attack));
    return math.modf(math.ceil(attack));
end
